import { CommunityPreview } from "@/components/CommunityPreview";
import { Navbar } from "@/components/Navbar";
import { Footer } from "@/components/Footer";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent } from "@/components/ui/card";
import { 
  Sparkles, 
  ArrowRight,
  Play,
  Package,
  Lightbulb,
  Settings,
  BookOpen,
  Zap,
  MessageCircle
} from "lucide-react";
import { Link } from "react-router-dom";
import { useState } from "react";
import { useRole } from "@/contexts/RoleContext";
import { StudentHome } from "@/components/StudentHome";
import { TeacherHome } from "@/components/TeacherHome";
import { ModuleCards } from "@/components/ModuleCards";

// Sample community members data
const communityMembers = [
  {
    id: "1",
    name: "Alex Johnson",
    interests: ["AI Learning", "Psychology", "Creative Writing"]
  },
  {
    id: "2",
    name: "Jamie Smith",
    interests: ["Data Science", "Machine Learning", "Research"]
  },
  {
    id: "3",
    name: "Morgan Lee",
    interests: ["Educational Technology", "UX Design", "Innovation"]
  }
];

const Index = () => {
  const { role } = useRole();
  // 删除 showRoleSelection、handleGetStarted、handleRoleSelect 相关状态和方法

  // 删除 RoleSelection 相关渲染逻辑

  return (
    <div className="min-h-screen flex flex-col bg-white">
      <Navbar />

      <main className="flex-1">
        {/* Render role-specific content or default home */}
        {role === 'student' && <StudentHome />}
        {role === 'teacher' && <TeacherHome />}
        
        {/* 其余内容保持不变 */}

        {/* Module Cards - shown only for teachers */}
        {role === 'teacher' && <ModuleCards />}

        {/* Community Section - shown for all roles and home page only */}
        <section className="py-20 bg-gray-50">
          <div className="container mx-auto px-4">
            <div className="text-center mb-16">
              <h2 className="text-4xl md:text-5xl font-bold mb-6 text-gray-900">
                Join Our Learning Community
              </h2>
              <p className="text-xl text-gray-600 max-w-3xl mx-auto">
                Connect with thousands of learners worldwide and accelerate your growth through collaborative learning.
              </p>
            </div>
            
            <div className="max-w-2xl mx-auto">
              <CommunityPreview members={communityMembers} />
            </div>
          </div>
        </section>

        {/* CTA Section */}
        <section className="py-20 bg-purple-600">
          <div className="container mx-auto px-4 text-center">
            <h2 className="text-4xl md:text-5xl font-bold mb-6 text-white">
              {role === 'teacher' ? 'Start Your Teaching Journey Today' : 'Start Your Learning Journey Today'}
            </h2>
            <p className="text-xl text-purple-100 max-w-3xl mx-auto mb-8">
              {role === 'teacher' 
                ? "Join thousands of successful educators who have transformed their education with Mevolution's AI-powered platform."
                : "Join thousands of successful learners who have transformed their education with Mevolution's AI-powered platform."
              }
            </p>
            {!role ? (
              <Button 
                size="lg" 
                className="bg-white text-purple-600 hover:bg-gray-50 px-8 py-4 text-lg h-14 rounded-lg font-semibold"
                // 删除 handleGetStarted 调用
              >
                Get Started Free
                <ArrowRight className="w-5 h-5 ml-2" />
              </Button>
            ) : (
              <Button asChild size="lg" className="bg-white text-purple-600 hover:bg-gray-50 px-8 py-4 text-lg h-14 rounded-lg font-semibold">
                <Link to="/discover">
                  {role === 'teacher' ? 'Continue Teaching' : 'Continue Learning'}
                  <ArrowRight className="w-5 h-5 ml-2" />
                </Link>
              </Button>
            )}
          </div>
        </section>
      </main>

      <Footer />
    </div>
  );
};

export default Index;
